package com.example.secondhandspringboot.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.secondhandspringboot.domain.entity.Goods;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.secondhandspringboot.domain.entity.GoodsCounted;
import com.example.secondhandspringboot.domain.vo.GoodsVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 周在林
 * @since 2024-04-01
 */

public interface GoodsMapper extends BaseMapper<Goods> {
    Page<GoodsVO> getGoodsVoBySchoolId(Long schoolId, Page<GoodsVO> page);

    Page<GoodsVO> searchGoods(Long schoolId, Page<GoodsVO> page1, String search);


    List<GoodsVO> getRecommendGoodsBySchoolId(Long schoolId, int num);

    List<GoodsVO> getHotTopNum(Long schoolId, int hotTopGoodsNum);

    Page<GoodsVO> getMyPushGoods(Long currentId, Page<GoodsVO> page1);

    @Select("""
            select distinct category_id
            from goods
            where match(goods_name,description) against (#{searchKey} in boolean mode) and deleted=0
            """)
    List<Long> getCategoryIdBySearchKey(String searchKey);

    GoodsVO getGoodsVoByCategoryIdAndSchoolId(Long categoryId, Long schoolId, int lookedNums);
}
